package com.bite.demospringmvc;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
@RequestMapping("/res")
public class ResponseController {
    @RequestMapping("/index")
    public Object index(){
        return "/index.html";
    }

    @ResponseBody
    @RequestMapping("/data")
    public String data(){
        return "我是数据";
    }

    @ResponseBody
    @RequestMapping("/returnHtml")
    public String returnHtml(){
        return "<h1> wwwww</h1>";
    }

    @ResponseBody
    @RequestMapping("/status")
    public String setStatus(HttpServletResponse response){
        response.setStatus(418);
        return "设置状态码成功";
    }
}
